﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Randata.Helpers
{
    internal static class IEnumerableExtentions
    {

        public static T AnyOne<T>(this IEnumerable<T> target)
        {
            T selected = default(T);

            int indexToGet = Rand.Instance.Next(0, target.Count());
            int index = 0;
            foreach (T t in target)
            {
                if (index == indexToGet)
                    selected = t;

                index++;
            }
            
            return selected;
        }

    }
}
